--[[ 编码: WMS-81-02 名称: 出入库测试-创建后 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: AfterDataObjCreate 功能: -- 如果是 入库 创建后,会把 容器和目标货位进行绑定,并且增加库区、仓库量 -- 如果是 出库 创建后,容器和货位解绑,减库区、仓库量 更改记录: --]] wms_wh = require( "wms_wh" ) wms_cntr = require( "wms_container" ) function AfterDataObjCreate ( strLuaDEID ) local nRet, strRetInfo -- step1: 获取当前【出入库测试】对象 local test nRet, test = m3.GetSysCurEditDataObj( strLuaDEID, "WMS_TEST_WH_IO" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..test ) end if ( test.cntr_code == '' or test.cntr_code == nil ) then lua.Error( strLuaDEID, debug.getinfo(1), "容器号不能为空! " ) end if (test.test_type == "入库") then if (test.loc_code == nil or test.loc_code == nil ) then lua.Error( strLuaDEID, debug.getinfo(1), "入库必须要确定货位! " ) end local loc nRet, loc = wms_wh.GetLocInfo( test.loc_code) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "WMS_GetLocInfo失败! "..loc ) end nRet, strRetInfo = wms_wh.Loc_Container_Binding( strLuaDEID, test.loc_code, test.cntr_code, "绑定解绑方法-人工", "测试数据用例" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '货位容器绑定失败!'..strRetInfo ) end -- 加库区/库量表 (通过CG_Detail) nRet, strRetInfo = wms_base.Add_WHAreaQty_ByCGDetail(strLuaDEID, loc.wh_code, loc.area_code, test.cntr_code ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end else local loc_code = wms_wh.GetLocCodeByCNTR( strLuaDEID, test.cntr_code ) if ( loc_code == "") then lua.Error( strLuaDEID, debug.getinfo(1), "容器号'"..test.cntr_code.."'没有和货位绑定!" ) end local loc bRet, loc = wms_wh.GetLocInfo( loc_code) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "WMS_GetLocInfo失败! "..loc ) end nRet, strRetInfo = wms_wh.Loc_Container_Unbinding( strLuaDEID, loc.code, test.cntr_code, "绑定解绑方法-人工", "测试数据用例" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '货位容器绑定失败!'..strRetInfo ) end -- 减库区/仓库量表 (通过CG_Detail) nRet, strRetInfo = wms_base.Reduce_WHAreaQty_ByCGDetail(strLuaDEID, loc.wh_code, loc.area_code, test.cntr_code ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), 'wms_base.Reduce_WHAreaQty_ByCGDetail失败!'..strRetInfo ) end end end